{extend name="layout/layout" /}
<!--请在下方写此页面body相关内容-->
{block name="container"}
<div class="page-container">
    <form action="<?php echo url('admin/adminList')?>" method="get">
        <div class="text-c">
            <input type="text" class="input-text" style="width:250px" placeholder="输入用户名" name="search_name" value="<?php echo isset($params['search_name']) ? $params['search_name'] : ''?>">
            <button type="submit" class="btn btn-success radius"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
        </div>
    </form>
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l"> <a href="javascript:;" onclick="show('添加管理员','{:url('admin/adminsave')}','','400')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加管理员</a></span>
        <span class="r mt-5">共有记录：<strong><?php echo $list->total()?></strong> 条</span>
    </div>
    <table class="table table-border table-bordered table-hover table-bg table-sort mt-10">
        <thead>
        <tr class="text-c">
            <th width="40">ID</th>
            <th width="150">用户名</th>
            <th>角色名称</th>
            <th width="80">最后登录IP</th>
            <th width="120">最后登录时间</th>
            <th width="120">创建时间</th>
            <th width="120">更新时间</th>
            <th width="70">状态</th>
            <th width="100">操作</th>
        </tr>
        </thead>
        <tbody>
        <?php foreach($list->items() as $v){?>
        <tr class="text-c">
            <td><?php echo $v['id']?></td>
            <td><?php echo $v['username']?></td>
            <td><?php echo $v['group_name']?></td>
            <td><?php echo $v['last_login_ip'] ? long2ip($v['last_login_ip']) : '-'?></td>
            <td><?php echo $v['last_login_time'] ? date('Y-m-d H:i:s',$v['last_login_time']) : '-'?></td>
            <td><?php echo empty($v['create_time']) ? '-' : date('Y-m-d H:i:s',$v['create_time'])?></td>
            <td><?php echo empty($v['update_time']) ? '-' : date('Y-m-d H:i:s',$v['update_time'])?></td>
            <td class="td-status">
                <span class="label <?php echo $v['status'] == 1 ? 'label-success' : 'label-defaunt';?> radius">
                    <?php echo $v['status'] == 1 ? '已启用' : '已禁用';?></span></td>
            <td class="td-manage">
                <?php if($v['status'] == 1){?>
                <a href="javascript:;" title="禁用" onclick="status(this,'<?php echo url('admin/status')?>','<?php echo $v['id']?>', 2, '禁用')"><i class="Hui-iconfont">&#xe60e;</i></a>
                <?php } if($v['status'] == 2) {?>
                <a href="javascript:;" title="启用" onclick="status(this,'<?php echo url('admin/status')?>','<?php echo $v['id']?>', 1, '启用')"><i class="Hui-iconfont">&#xe605;</i></a>
                <?php }?>
                <a class="ml-5" href="javascript:;" title="重置密码" onclick="resetPassword(this,'<?php echo url('admin/resetPassword')?>', '<?php echo $v['id']?>')"><i class="Hui-iconfont">&#xe63f;</i></a>
                <a class="ml-5" href="javascript:;" title="编辑"  onclick="show('管理员编辑','<?php echo url('admin/adminSave',['id'=>$v['id']])?>','','400')"><i class="Hui-iconfont">&#xe6df;</i></a>
            </td>
        </tr>
        <?php } if(!$list->items()){?>
        <tr class="text-l"><td colspan="20">没有找到匹配的记录</td></tr>
        <?php }?>
        </tbody>
    </table>
    <span class="r pages mt-10"><?php echo $list->render();?></span>
</div>
{/block}
<!--请在上方写此页面body相关内容-->

<!--请在下方写此页面业务相关的脚本-->
{block name="js"}
<script type="text/javascript">
function resetPassword(obj, url, id) {
    layer.confirm('确认要重置吗？',function(){
        $.ajax({
            type: 'post',
            url: url,
            data: {id: id},
            success:function(data){
                if(data.code !== 0){
                    layer.msg(data.msg,{ icon:5, time:2000 });
                } else {
                    layer.msg('已重置！',{icon: 1,time:1000});
                }
            }
        });
    });
}
</script>
{/block}
<!--/请在上方写此页面业务相关的脚本-->